/* type 与  interface
  interface可以重复写同名的
  type 不能
*/
type MyType={
    name:string,
    age:number,
    // [propName:string]:any,
    say():void
}

let a:MyType
a={
    name:'aa',
    age:12,
    // sex:1,
    say(){
        console.log('111')
    }
}
console.log(a)
console.log(a.say())

class typeCls implements MyType{
    name:string;
    age:number;
    constructor(name:string,age:number){
        this.age=age;
        this.name=name;
    }
    say(){
        console.log('我是用type实现的')
    }
}

const ClsType=new typeCls('理想',20)
ClsType.say()


type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE'
let method: Methods
method = 'PUT' // OK
// method = 'aaa' // error

interface MyInter{
    name:string,
    age:number,
    say():void
}

class MYinter implements MyInter{
    name:string;
    age:number;
    constructor(name:string,age:number){
        this.name=name;
        this.age=age;
    }
    say(){
        console.log(`大家好，我是${this.name},今年${this.age}`)
    }
}

const myInterCls=new MYinter('小白',15)
myInterCls.say()